/**
 * 
 */
package com.yidin.lsc;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.yidin.entry.CouponAdapter;
import com.yidin.widget.Carema;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

/**
 * 优惠券类
 * @author cola
 *
 */
public class Coupon extends Container {
	private Map<Button, View> group;
	private ViewGroup ViewContainer;
	private Button aboutBtn;
	private Button dynamicBtn;
	private ListView myListView;
	private CouponAdapter myAdapter;
	private List<CouponItem> filterArray;
	private TextView search;
	
	public Coupon(Activity activity, View contentView, Views father) {
		super(activity, contentView, father);
		// TODO Auto-generated constructor stub
		initialize();
	}

	@Override
	public void checkCache() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void findView(View contentView) {
		// TODO Auto-generated method stub
//		View view = inflater.inflate(R.layout.coupon, null);
//
//		ViewContainer.addView(view);
		this.aboutBtn = (Button) contentView.findViewById(R.id.ButtonAbout);
//		group.put(this.aboutBtn, view);
		this.dynamicBtn = (Button) contentView.findViewById(R.id.ButtonDynamic);
		this.myListView = (ListView) contentView.findViewById(R.id.couponListView);
		this.search = (TextView) contentView.findViewById(R.id.search);
		this.search.requestFocus();
		this.search.setOnClickListener(searchOnClickListener);
		((TextView) contentView.findViewById(R.id.title)).setText("优惠券");
	}

	@Override
	public void showFunctionsListView(View contentView) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void initialize() {
		// TODO Auto-generated method stub
		filterArray = new ArrayList<CouponItem>();
		CouponItem ci = new CouponItem();
		ci.imageUrl = "jjd";
		ci.type = "d";
		CouponItem ci2 = new CouponItem();
		ci2.imageUrl = "jjd";
		ci2.type = "d";
		filterArray.add(ci2);
		
		this.myAdapter = new CouponAdapter(activity,filterArray);
		this.myListView.setAdapter(myAdapter);
		//myAdapter.notifyDataSetChanged();
	}

	private OnClickListener searchOnClickListener = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			Intent it = new Intent(activity,Carema.class);
			activity.startActivity(it);
		}

	};
	
	@Override
	public void removeView() {
		// TODO Auto-generated method stub
	}

	@Override
	public void refresh(Object... param) {
		// TODO Auto-generated method stub
		
	}

	public class CouponItem{
		public String imageUrl;
		public String type;
	}
}
